import { Vector3 } from "@minecraft/server";
import { GameComponentType } from "@sapi-game/gameComponent/gameComponent";
import { SphereRegion } from "@sapi-game/gameRegion/gameRegion";
import { DimensionIds } from "@sapi-game/utils/vanila-data";
import { WereWolfChestLoader } from "./components/chestLoader";
import { BeforeNightCampView } from "./views/camp/beforeNight";
import { DisussCampView } from "./views/camp/discuss";
import { FirstDayCampView } from "./views/camp/firstDay";
import { HunterCampView } from "./views/camp/hunter";
import { MorningCampView } from "./views/camp/morning";
import { OutCampView } from "./views/camp/out";
import { PickNumberCampView } from "./views/camp/pickNo";
import { SeerCampView } from "./views/camp/seer";
import { VoteCampView } from "./views/camp/vote";
import { WitchCampView } from "./views/camp/witch";
import { WolfCapmView } from "./views/camp/wolf";
import { BeforeMorningClassicView } from "./views/classic/beforeMorning";
import { BeforeNightClassicView } from "./views/classic/beforeNight";
import { DiscussClassicView } from "./views/classic/discuss";
import { FirstDayClassicView } from "./views/classic/firstDayClaasic";
import { HunterClassicView } from "./views/classic/hunter";
import { MorningClassicView } from "./views/classic/morning";
import { OutClaasicPhase } from "./views/classic/out";
import { PickNumberClaasicView } from "./views/classic/pickNumber";
import { SeerClassicView } from "./views/classic/seer";
import { VoteClassicView } from "./views/classic/vote";
import { WitchClassicView } from "./views/classic/witch";
import { WolfClassicView } from "./views/classic/wolf";
import { WereWolfRoleActionbar } from "./components/roleActionbar";
import { beforeMorningCampView } from "./views/camp/beforeMorning";

export interface WereWolfMapData {
    /**等待地点 */
    watingRegion: SphereRegion;
    locations: {
        speakingPos: number[][];
        speakingLookingPos: Vector3;
        housePos: number[][];
    };
    /**是否展示剩余时间 */
    showTime: boolean;
    settingButtonLoc: [number, number, number];
    spawnPoint: Vector3;
    mainView: GameComponentType<any>[];
    pickNoView: GameComponentType<any>[];
    phaseViews: {
        firstDay: GameComponentType<any>[];
        beforeNight: GameComponentType<any>[];
        seer: GameComponentType<any>[];
        wolf: GameComponentType<any>[];
        witch: GameComponentType<any>[];
        beforeMorning: GameComponentType<any>[];
        morning: GameComponentType<any>[];
        hunter: GameComponentType<any>[];
        discuss: GameComponentType<any>[];
        vote: GameComponentType<any>[];
        out: GameComponentType<any>[];
    };
}

const classicMap: WereWolfMapData = {
    watingRegion: new SphereRegion(
        DimensionIds.Overworld,
        { x: -96, y: -50, z: -105 },
        15
    ),
    settingButtonLoc: [-100, -49, -98],
    locations: {
        speakingPos: [
            [-57.5, -60, -105.5],
            [-55.5, -60, -110.5],
            [-50.5, -60, -112.5],
            [-45.5, -60, -110.5],
            [-43.5, -60, -105.5],
            [-45.5, -60, -100.5],
            [-50.5, -60, -98.5],
            [-55.5, -60, -100.5],
        ],
        speakingLookingPos: { x: -50.5, y: -59.0, z: -105.5 },
        housePos: [
            [-70, -56, -105],
            [-62.5, -56, -120.5],
            [-50.5, -56, -124.5],
            [-37, -56, -123.5],
            [-29.5, -56, -106.5],
            [-37, -56, -90],
            [-49, -56, -87],
            [-62, -56, -87],
        ],
    },

    showTime: true,
    spawnPoint: { x: -83, y: -59, z: -70 },
    mainView: [],
    pickNoView: [PickNumberClaasicView],
    phaseViews: {
        firstDay: [WereWolfChestLoader, FirstDayClassicView],
        beforeNight: [BeforeNightClassicView],
        seer: [SeerClassicView],
        wolf: [WereWolfChestLoader, WolfClassicView],
        witch: [WitchClassicView],
        beforeMorning: [BeforeMorningClassicView],
        morning: [MorningClassicView],
        hunter: [HunterClassicView],
        discuss: [DiscussClassicView],
        vote: [VoteClassicView],
        out: [OutClaasicPhase],
    },
};

const campMap: WereWolfMapData = {
    watingRegion: new SphereRegion(
        DimensionIds.Overworld,
        { x: -177, y: -29, z: -133 },
        30
    ),
    showTime: false,
    settingButtonLoc: [-177, -27, -138],
    spawnPoint: { x: -203, y: -21, z: -222 },
    locations: {
        speakingLookingPos: { x: -201, y: -45, z: -181 },
        speakingPos: [
            [-200.5, -46, -188.5],
            [-194.5, -46, -186.5],
            [-192.5, -46, -180.5],
            [-194.5, -46, -174.5],
            [-200.5, -46, -172.5],
            [-206.5, -46, -174.5],
            [-208.5, -46, -180.5],
            [-206.5, -46, -186.5],
        ],
        housePos: [
            [-200.5, -45.94, -205.35],
            [-181.51, -45.94, -194.55],
            [-174.59, -45.94, -180.57],
            [-181.59, -45.94, -166.34],
            [-200.66, -45.94, -155.54],
            [-219.57, -45.94, -166.43],
            [-226.1, -45.94, -180.24],
            [-219.69, -45.94, -194.56],
        ],
    },
    mainView: [WereWolfRoleActionbar],
    pickNoView: [PickNumberCampView],
    phaseViews: {
        firstDay: [FirstDayCampView],
        beforeNight: [BeforeNightCampView],
        seer: [SeerCampView],
        wolf: [WolfCapmView],
        witch: [WitchCampView],
        beforeMorning: [beforeMorningCampView],
        morning: [MorningCampView],
        hunter: [HunterCampView],
        discuss: [DisussCampView],
        vote: [VoteCampView],
        out: [OutCampView],
    },
};

export const WereWolfMaps = {
    /**经典地图 */
    classic: classicMap,
    /**营地地图 */
    camp: campMap,
};
